<template>
  <div>
    <el-descriptions title="用户信息">
      <el-descriptions-item label="用户ID">{{userInfo.id}}</el-descriptions-item>
      <el-descriptions-item label="账号">{{userInfo.account}}</el-descriptions-item>
      <el-descriptions-item label="用户名">{{userInfo.userName}}</el-descriptions-item>
      <el-descriptions-item label="手机号码">{{userInfo.phone}}</el-descriptions-item>
      <el-descriptions-item label="性别">{{userInfo.sex===true?"男":"女"}}</el-descriptions-item>
      <el-descriptions-item label="生日">{{userInfo.birthday}}</el-descriptions-item>
      <el-descriptions-item label="状态">
        <el-tag size="small">有效</el-tag>
      </el-descriptions-item>
    </el-descriptions>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>近期订单</span>
      </div>
      <el-table
          :data="tableData"
          border
          style="width: 100%">
        <el-table-column
            prop="id"
            label="订单号"
            width="180">
        </el-table-column>
        <el-table-column
            prop="userName"
            label="用户名"
            width="180">
        </el-table-column>
        <el-table-column
            prop="deskNo"
            label="茶桌编号">
        </el-table-column>
        <el-table-column
            prop="createTime"
            label="订单时间">
        </el-table-column>
        <el-table-column
            prop="price"
            label="消费">
        </el-table-column>
        <el-table-column
            prop="teaMsg"
            label="消费明细">
          <template slot-scope="scope">
            <p v-for="item in scope.row.teaMsg">
              {{item}}
            </p>
          </template>
        </el-table-column>
        <el-table-column
            prop="dataStatus"
            label="订单状态">
          <template slot-scope="scope">
            {{scope.row.dataStatus ===false?'退款':'有效'}}
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>

</template>

<script>
import {doGetOrder} from "@/api/order";
import {doGetUserByToken} from "@/api/user";

export default {
  name: "dash",
  data() {
    return{
      tableData: [],
      userInfo:{}
    }
  },mounted() {

    const obj = {
      pageIndex: 1,
      pageSize: 20,
      queryInfo:{
        token:window.localStorage.getItem("token")
      }
    }
    doGetOrder(obj).then(res=>{
      if (res.code===200){
        this.tableData = res.data.records;
      }
    });
    doGetUserByToken(window.localStorage.getItem("token")).then(res=>{
      if (res.code===200){
        this.userInfo=res.data;
      }
    })
  }
}
</script>

<style lang="less" scoped>
.box-card{
  margin-top: 20px;
}
</style>